home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-12-05 | 2.9 KB | 115 lines | [TEXT/PJMM] |
- unit GraphSubs;
-
- { bits are ©1991 Quinn "The Eskimo", but not all of it}
-
- interface
-
- procedure ScaleRect (r1, r2: Rect; numer, denom: integer; var r3: rect);
- procedure ZoomRect (srcrect, dstrect: Rect; var pat: Pattern);
- function CentreString (r: rect; s: str255): point;
- function GetMenuFlash: integer;
- procedure CentreRect (inrect: rect; var centrect: rect);
-
- procedure PlotSICN (r: rect; sicnList: Handle; index: longint);
-
- implementation
-
- procedure ScaleRect (r1, r2: Rect; numer, denom: integer; var r3: rect);
- procedure doit (p1, p2: integer; var p3: integer);
- begin
- p3 := p1 + ((p2 - p1) * numer) div denom;
- end; { doit }
- begin
- doit(r1.top, r2.top, r3.top);
- doit(r1.left, r2.left, r3.left);
- doit(r1.bottom, r2.bottom, r3.bottom);
- doit(r1.right, r2.right, r3.right);
- end; { ScaleRect }
-
- procedure ZoomRect (srcrect, dstrect: Rect; var pat: Pattern);
- const
- kZoomMax = 10;
- kDelay = 4;
- var
- junk: longint;
- i: integer;
- ps: PenState;
- r: rect;
- begin
- GetPenState(ps);
- PenNormal;
- PenMode(patXor);
- PenPat(pat);
- r := srcrect;
- FrameRect(r);
- Delay(kDelay, junk);
- for i := 1 to kZoomMax do begin
- FrameRect(r);
- ScaleRect(srcrect, dstrect, i, kZoomMax, r);
- FrameRect(r);
- Delay(kDelay, junk);
- end; { for }
- Delay(kDelay, junk);
- FrameRect(r);
- SetPenState(ps);
- end; { ZoomRect }
-
- function CentreString (r: rect; s: str255): point;
- var
- finfo: fontInfo;
- h, w: integer;
- p: point;
- begin
- GetFontInfo(finfo);
- h := finfo.ascent + finfo.descent;
- w := StringWidth(s);
- p.v := r.top + ((r.bottom - r.top - h) div 2) + finfo.ascent;
- p.h := r.left + ((r.right - r.left - w) div 2);
- CentreString := p;
- end;
-
- procedure CentreRect (inrect: rect; var centrect: rect);
- var
- centwidth, centheight: integer;
- inwidth, inheight: integer;
- begin
- centwidth := centrect.right - centrect.left;
- centheight := centrect.bottom - centrect.top;
- inwidth := inrect.right - inrect.left;
- inheight := inrect.bottom - inrect.top;
- OffsetRect(centrect, -centrect.left + inrect.left, -centrect.top + inrect.top);
- OffsetRect(centrect, (inwidth - centwidth) div 2, (inheight - centheight) div 2);
- end;
-
- function GetMenuFlash: integer;
- type
- intPtr = ^integer;
- const
- MenuFlash = $A24;
- begin
- GetMenuFlash := intPtr(MenuFlash)^;
- end; { GetMenuFlash }
-
- procedure PlotSICN (r: rect; sicnList: Handle; index: longint);
- type
- SICNdata = array[0..1000] of array[1..16] of integer;
- SICNptr = ^SICNdata;
- SICNhand = ^SICNptr;
- var
- state: byte;
- srcBits: BitMap;
- port: GrafPtr;
- sic: SICNhand;
- begin
- state := HGetState(sicnList);
- HLock(sicnList);
- sic := SICNhand(sicnList);
- srcBits.baseAddr := Ptr(@sic^^[index]);
- srcBits.rowBytes := 2;
- SetRect(srcBits.bounds, 0, 0, 16, 16);
- GetPort(port);
- CopyBits(srcBits, port^.portBits, srcBits.bounds, r, srcCopy, nil);
- HSetState(sicnList, state);
- end; { PlotSICN }
-
- end. { GraphSubs }